namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0148 : DbMigration
    {
        public override void Up()
        {
            AddColumn("dbo.message_send", "from_pos_seq", c => c.Int());
            AddColumn("dbo.message_send", "to_pos_seq", c => c.Int());
            AddColumn("dbo.message_send", "wod_emp_seq", c => c.Int());
            AddColumn("dbo.message_reply", "from_pos_seq", c => c.Int());
            AddColumn("dbo.message_reply", "to_pos_seq", c => c.Int());
            AddColumn("dbo.message_reply", "wod_emp_seq", c => c.Int());
            Sql(
                @"/* -- update this after migrated */
UPDATE message_send
SET message_send.from_pos_seq = hrm_ps_employees.pos_seq
FROM message_send
INNER JOIN hrm_ps_employees
ON message_send.from_emp_seq = hrm_ps_employees.emp_seq;

UPDATE message_send
SET message_send.to_pos_seq = hrm_ps_employees.pos_seq
FROM message_send
INNER JOIN hrm_ps_employees
ON message_send.to_emp_seq = hrm_ps_employees.emp_seq;

UPDATE message_reply
SET message_reply.from_pos_seq = hrm_ps_employees.pos_seq
FROM message_reply
INNER JOIN hrm_ps_employees
ON message_reply.from_emp_seq = hrm_ps_employees.emp_seq;

UPDATE message_reply
SET message_reply.to_pos_seq = hrm_ps_employees.pos_seq
FROM message_reply
INNER JOIN hrm_ps_employees
ON message_reply.to_emp_seq = hrm_ps_employees.emp_seq;
");
        }
        
        public override void Down()
        {
            DropColumn("dbo.message_reply", "wod_emp_seq");
            DropColumn("dbo.message_reply", "to_pos_seq");
            DropColumn("dbo.message_reply", "from_pos_seq");
            DropColumn("dbo.message_send", "wod_emp_seq");
            DropColumn("dbo.message_send", "to_pos_seq");
            DropColumn("dbo.message_send", "from_pos_seq");
        }
    }
}
